
let arrTopN = (arr = [], property = '', n = 1) => {
    property = property.replace(/(^\s*)|(\s*$)/g,'');
    if (arr.length === []) {
        return ;
    } else {
        arr = Array.prototype.slice.call(arr);
    }
    arr.sort((a, b) => {
        if (!property) {
            return b - a;
        } else {
            return b[property] - a[property];
        }
    });
    return arr.slice(0, n);
}

export default {
    arrTopN
};